#include"vcryd.h"
void xor(PUCHAR text);
extern "C" NTSTATUS Crypt(PVOID text, PUCHAR key, ULONG length)
{
	if(text==NULL) return STATUS_INVALID_PARAMETER;
	DbgPrint("In %s \n",__FUNCTION__);
	NTSTATUS status=STATUS_SUCCESS;
	PUCHAR currentBlock=(PUCHAR)text;
	for(unsigned int i=0;i<length/16;i++)
	{
		
		xor(currentBlock);
		currentBlock+=16;
	}
	return status;
}





extern "C" NTSTATUS DeCrypt(PVOID text, PUCHAR key, ULONG length)
{
	if(text==NULL) return STATUS_INVALID_PARAMETER;
	DbgPrint("In %s \n",__FUNCTION__);
	DbgPrint("length=%d\n",length);
	PUCHAR currentBlock=(PUCHAR)text;
	for(unsigned int i=0;i< (length/16);++i)
	{
		
		
		xor(currentBlock);
		currentBlock+=16;
			
	}
	DbgPrint("\n");
	NTSTATUS status = STATUS_SUCCESS;
    return status;
}


void xor(PUCHAR text)
{
	//if(text==NULL) DbgPrint("STATUS_INVALID_PARAMETER\n");
	//DbgPrint("In %s \n",__FUNCTION__);	
	UCHAR key[16]={0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76};
	for(int i=0;i<16;i++) text[i]=text[i]^key[i];
}